package cn.tedu.clyback.permission.service;

import cn.tedu.clyback.RolePermission.pojo.vo.RolePermissionVO;
import cn.tedu.clyback.permission.mapper.PermissionMapper;
import cn.tedu.clyback.permission.pojo.dto.PermissionSelectParam;
import cn.tedu.clyback.permission.pojo.entity.Permission;
import cn.tedu.clyback.permission.pojo.vo.PermissionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;
    @Override
    public List<PermissionVO> getPermission(PermissionSelectParam permissionSelectParam) {
        List<PermissionVO> list = permissionMapper.getPermission(permissionSelectParam);
        return list;
    }

    @Override
    public void deletePermission(Integer permissionId) {
        permissionMapper.deletePermission(permissionId);
    }

    @Override
    public void savePermission(Permission permission) {
        if (permission.getPermissionId()==null){
            permissionMapper.create(permission);
        }else {
            permissionMapper.update(permission);
        }
    }

    @Override
    public List<PermissionVO> unselectPermission(Integer roleId) {
        List<PermissionVO> list=permissionMapper.unselectPermission(roleId);
        return list;
    }

    @Override
    public List<RolePermissionVO> selectuserroleById(Integer roleId) {
       List<RolePermissionVO> list=permissionMapper.selectuserroleById(roleId);
       return list;
    }
}
